<?php
/**
 * Jishupu-Laravel-Vue-Admin
 * @Author:技术铺<jishupu@qq.com>
 * @Date: 2021/11/11
 */

namespace App\Http\Resources;

/**
 * 操作日志模块资源
 * Class AdminLogResource
 * @package App\Http\Resources
 */
class AdminLogResource extends BaseResource
{
    /**
     * @param \Illuminate\Http\Request $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        return $this->filterFields([
            'id' => $this->id,
            'content' => $this->content,
            'request_uri' => $this->request_uri,
            'request_method' => $this->request_method,
            'request_parameters' => $this->request_parameters,
            'request_ip' => $this->request_ip,
            'request_user_agent' => $this->request_user_agent,
            'request_browser' => $this->request_browser." ". $this->request_browser_version,
            'request_platform' => $this->request_platform." ". $this->request_platform_version,
            'action' => $this->action,
            'action_controller' => $this->action_controller,
            'action_controller_name' => $this->action_controller_name,
            'action_method' => $this->action_method,
            'action_method_name' => $this->action_method_name,
            'route_as_name' => $this->route_as_name,
            'response' => $this->response,
            'exception' => $this->exception,
            'status' => $this->status,
            'created_user_name' => ($this->user ? $this->user->name : ($this->admin_username ?? '')),
            'created_at' => $this->created_at ? $this->created_at->format('Y-m-d H:i:s') : ""
        ]);
    }
}
